using System;
using System.ComponentModel;
using System.Windows.Forms;

namespace SqlRunner.controls
{
	/// <summary>
	/// Summary description for TimerExtended.
	/// </summary>
	public class TimerExtended:Timer
	{
		#region Private Instances

		private DateTime startTime;

		#endregion
		#region Constructor

		public TimerExtended(IContainer container):base(container)
		{
			base.Enabled = false;
			base.Interval = 1000;
			//base.Tick += new EventHandler(TimerExtended_Tick);
		}

		#endregion
		#region Private Methods

		private void TimerExtended_Tick(object sender, EventArgs e)
		{

		}

		#endregion
		#region Public Methods

		public override bool Enabled
		{
			get{ return base.Enabled; }
			set
			{
				if ( value == true )
				{
					startTime = DateTime.Now;
				}
				base.Enabled = value;
			}
		}

		public string ElapsedTime
		{
			
			get
			{
				TimeSpan duration = DateTime.Now - startTime;
				return duration.ToString().Substring(0, 8);
			}
		}

		#endregion


	}
}
